package com.shenda.api.web;

import java.util.concurrent.CompletableFuture;

import com.shenda.api.dto.LogDTO;
import com.shenda.api.entity.Log;
import com.shenda.api.service.LogServiceAsync;
import com.swak.annotation.FluxReferer;
import com.swak.annotation.PostMapping;
import com.swak.annotation.RestApi;
import com.swak.entity.Parameters;
import com.swak.entity.Result;
import com.swak.utils.Functions;

/**
 * 日志 -- 管理
 * 
 * @author lifeng
 */
@RestApi(path = "/api/admin/log", value = "adminLogApi")
public class LogApi {

	/**
	 * 日志服务
	 */
	@FluxReferer
	private LogServiceAsync logService;

	/**
	 * 分页数据管理
	 * 
	 * @return
	 */
	@PostMapping("/page")
	public CompletableFuture<Result> page(Log query, Parameters param) {
		return logService.page(query, param).thenApply(page -> LogDTO.convertPage(page))
				.thenApply(Functions.resultFunction());
	}

	/**
	 * 分页数据管理
	 * 
	 * @return
	 */
	@PostMapping("/news")
	public CompletableFuture<Result> news(Log query) {
		return logService.news(query).thenApply(Functions.resultFunction());
	}
}